
import 'package:cunyutech_flutter_ui/src/theme/main.dart';
import 'package:flutter/widgets.dart';

class CYToggleIconButton extends StatelessWidget {

  final double size;
  final String icon;
  final VoidCallback onTap;
  final bool actived;
  final String activeIcon;
  final EdgeInsetsGeometry margin;

  const CYToggleIconButton({
    Key key, 
    this.actived, 
    this.activeIcon, 
    this.size = CYHeight.Default, 
    this.icon, 
    this.onTap,
    this.margin,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var cs = CYThemeData.of(context);
    return Container(
      margin: margin,
      child: GestureDetector(
        onTap: onTap,
        child: Container(
          width: size,
          height: size,
          child: Image.asset(actived ? activeIcon : icon, color: actived ? cs.primaryColor : cs.primaryForeColor ,),
        ),
      ),
    );
  }
}